{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3e25f36e",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np \n",
    "df_topo = pd.read_csv(\"data/location_info_of_ssd.csv\")\n",
    "df_all = pd.read_csv(\"data/20191231.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "d8c9a7f2",
   "metadata": {},
   "outputs": [],
   "source": [
    "apps = ['WSM', 'RM', 'WPS', 'DB', 'SS', 'DAE', 'NAS', 'WS']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "7605507f",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_topo = df_topo[df_topo['app'].isin(apps)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "d7fe1ff5",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_all = df_all.merge(df_topo[['model', 'disk_id', 'app']], how='left', on=['model', 'disk_id'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "8d1944b9",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_all = df_all[df_all['app'].isin(apps)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "62b52f99",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_all = df_all[['disk_id', 'app', 'r_241', 'r_242']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "9b1979ba",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_all = df_all.dropna(subset=['r_241', 'r_242'], how='any')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "ef97218f",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_all['wr'] = df_all['r_241'] / (df_all['r_242']+df_all['r_241'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "e1095b7e",
   "metadata": {},
   "outputs": [],
   "source": [
    "res_df = df_all.groupby(['app'])['wr'].mean().reset_index().rename(columns={'wr': 'mean'})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "7346604d",
   "metadata": {},
   "outputs": [],
   "source": [
    "res_df['mean'] = res_df['mean'] * 100"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "73285052",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:xlabel='Average percentage of ', ylabel='Writes(%)'>"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEGCAYAAABiq/5QAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAZjUlEQVR4nO3de7xcZX3v8c8XAggB5bZNIyAbJQVBJegugoJFIh48oEQFJAVOaKPpOS1FBK2xtd6Orx7sOYBaWyCCJd64S0nhxa05WBVCdBMCSYjILVgwkM0l3KRg4q9/PM+UYbL3np1k1pq99/N9v17zmrWeNWut30x2fvPMs9b6LUUEZmZWjs26HYCZmdXLid/MrDBO/GZmhXHiNzMrjBO/mVlhJnQ7gJHYeeedo7e3t9thmJmNKbfffvvjEdHT2j4mEn9vby/9/f3dDsPMbEyR9NBg7R7qMTMrjBO/mVlhnPjNzArjxG9mVhgnfjOzwjjxm5kVxonfzKwwTvxmZoVx4jczK0xlV+5K2gu4tKnpDcDnge/k9l5gJXBcRDxVVRxmNv70zrm249tceeaRHd/maFVZjz8i7omIqRExFXg78BvgKmAOsCAipgAL8ryZmdWkrqGeacD9EfEQcDQwL7fPA6bXFIOZmVFf4j8euDhPT4qIVXn6UWDSYCtImi2pX1L/wMBAHTGamRWh8sQvaUvgg8Dlrcsi3el90Lu9R8TciOiLiL6envWqipqZ2Uaqo8f/fmBxRDyW5x+TNBkgP6+uIQYzM8vqSPwzeHmYB2A+MDNPzwSu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wL8r3cKy3b0NRPoV1LGiXja+uMdvVTkG+G5E7B6peudupNseHgL8G/A24OO8/IvgNuBdkvYEkDRR0u8Pse3tgFWStiD1+Btu4+Xyxc1VV28A/qTpmMEuGvy+xZvluCHdQ+Cnke5F8KCkY/O6krRf64qRCmk9LGl6ft1W+djDSPfd7Nn8HuHlJN8ojnZM3t8a0t2cGgUGW9/v/8qfD5J+X6+8LSakgnXTJW2Tl32IpiJ2Nr458VtVZpDKyTa7kjTcs4401v3+/ExEDJDOZrlYqZrmQtKwyGD+hjSEcQvwi6b204DT8/p7kiqZEhE3koZCFubhkit4ObE2ex44IB8kPQz4cm4/AZgl6U7SWPjRg6wLqSLpqXn/twK/twH7bnYRcF4eqnkR+BZpPP8G0j2XG2aRKjsuIY3VP53bLwDuBhbn93I+Lb/uI2Jx3s/PSJ/lBRFxR5u4bJxwdU4bN3IP+4WICKU7Fs2IiKGS9GDrPxcRQ5UcHnUkbZvH55E0B5gcEZ/oclg2BniM38aTtwPfzMcL1gB/0t1wKnekpM+S/h8/RL01+20Mc4/fzKwwHuM3MyuME7+ZWWGc+M3MCuPEb2ZWGCd+M7PC/CeHsJVJ6ov4/wAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "res_df.plot(x = 'app', y = 'mean', kind='bar', rot = 0, xlabel = 'Average percentage of ', ylabel = 'Writes(%)', legend = None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "e9ac973f",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_std = df_all.groupby(['app'])['wr'].std().reset_index().rename(columns={'wr': 'std'})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "bd97563b",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_n = df_all.groupby(['app'])['wr'].count().reset_index().rename(columns={'wr': 'n'})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "d83a2a40",
   "metadata": {},
   "outputs": [],
   "source": [
    "res_df = res_df.merge(df_std, on=['app'])\n",
    "res_df = res_df.merge(df_n, on=['app'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "555f7415",
   "metadata": {},
   "outputs": [],
   "source": [
    "# compute 95% confidence interval\n",
    "res_df['conf'] = 1.96 * res_df['std'] / np.sqrt(res_df['n'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "4db43d66",
   "metadata": {},
   "outputs": [],
   "source": [
    "res_df['conf'] = res_df['conf'] * 100"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "51990d45",
   "metadata": {},
   "outputs": [],
   "source": [
    "res_df[['app', 'mean', 'conf']].to_csv(\"results/app_writes_percentage.csv\", index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "f4d34063",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.read_csv(\"data/ssd_failure_tag.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "dec39a8d",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_all = pd.read_csv(\"data/20191231.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "ce43525f",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_all = df_all.merge(df_topo[['model', 'disk_id', 'app']], how='left', on=['model', 'disk_id'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "388cda00",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_all = df_all[df_all['app'].isin(apps)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "a4aaf20c",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_all = df_all[['app', 'model']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "d6f69dd7",
   "metadata": {},
   "outputs": [],
   "source": [
    "res_all = df_all.groupby(['app']).count().reset_index().rename(columns={'model':'all'})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "8fff1079",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = df[['app','failure']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "7e0d9bb0",
   "metadata": {},
   "outputs": [],
   "source": [
    "res = df.groupby(['app']).count().reset_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "73430b99",
   "metadata": {},
   "outputs": [],
   "source": [
    "res = res[res['app'].isin(apps)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "17c23680",
   "metadata": {},
   "outputs": [],
   "source": [
    "res = res.merge(res_all[[ 'all', 'app']], how='left', on=['app'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "b3c21a77",
   "metadata": {},
   "outputs": [],
   "source": [
    "res['RFR'] = res['failure'] / res['all'] * 100"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "ef04f5c7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   app  failure     all       RFR\n",
      "0  DAE     1214   13324  9.111378\n",
      "1   DB      203   25393  0.799433\n",
      "2  NAS      541   12977  4.168914\n",
      "3   RM     3016   82952  3.635838\n",
      "4   SS      184   15642  1.176320\n",
      "5  WPS      529   34781  1.520945\n",
      "6   WS      232    8964  2.588130\n",
      "7  WSM     8916  329355  2.707109\n"
     ]
    }
   ],
   "source": [
    "print(res)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "22b6f85e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:xlabel='RFRs', ylabel='RFR(%)'>"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAEGCAYAAABvtY4XAAAAOXRFWHRTb2Z0d2FyZ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+SJ8xZ9qPppQK68nkqcF3/BnQdcA+6cvr6hp6U5BFJ7tvf3o7uA9hpZd9o5kXKNolMn6b7jf2sSQZb9NkkF2D2V/Q70X1A+FHgrUmW0x3V3X56ZFVdlu4UxEf1i16W5Pkj23pGVV2+WJlH1s+OwQf4BXDMFDLN50S6o0yAQ4Cr+rHGWV8GHprkPsBRwElJfk33Z3peVd06zbBVdV6S8+nedL4ysvxCFvHsmRF3A97Zn9l1C3Ap8BLgfUneB9wI/Ao4esq5LqA76+Pjc5bdraquSXK3DTxvd+D9/YeI0A0xTesU1E1lXrEI2RacqapuAN4CMOeciwVxqgJJalQTQzSSpDuy4CWpURa8JDXKgpekRlnwktQoC17brGx8RsrZWRRnf+6c5OgkM/397yXZ0Lw90pJgwWtbtrEZKWev4Jz9mZ2X5ZT+CtqDgdfNzgIoLUUWvNSZOyPlRlXVtXQXLN0HIMlz+t8EvpvkywNllDbL1nwlqzQRIzNSfnBk8ewkW9BNGPWiOc/ZG7grcH6/6PXAn1XVVZnSF8hIm2LBa1s2O3XEHnSz+I3OSDn7RRdzHZHk8cCDgWOr6jf98q8BH0lyKnD6cJGl8TlEo23ZRmek3IBT+m9leixwQpLfB6iqvwH+DtgLWDOlGTWljbLgtc3bxIyUG3rOarrJ4l4CkGSfqjq3ql5PN+e7H75q0VnwEt2MlHTj6ZvzvQFvAV6QZBfgn9J9ofI6uuljvztATGmzOJukJDXKI3hJapQFL0mNsuAlqVEWvCQ1yoKXpEZZ8JLUKAtekhr1/4dAgl6olAWsAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "res.plot(x = 'app', y = 'RFR', kind='bar', rot = 0, xlabel = 'RFRs', ylabel = 'RFR(%)', legend = None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "2b65efff",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   app       mean       std       n      conf\n",
      "0  DAE  58.363853  0.214614    3712  0.690415\n",
      "1   DB  40.871582  0.266851   21367  0.357810\n",
      "2  NAS  64.447986  0.089612    1783  0.415955\n",
      "3   RM  63.851844  0.272396   52312  0.233430\n",
      "4   SS  42.995601  0.263398   12477  0.462182\n",
      "5  WPS  28.246709  0.095436   11993  0.170807\n",
      "6   WS  71.073615  0.241670    7260  0.555918\n",
      "7  WSM  63.000880  0.173798  169258  0.082799\n"
     ]
    }
   ],
   "source": [
    "print(res_df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "a7bd0aed",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   app  failure     all       RFR\n",
      "0  DAE     1214   13324  9.111378\n",
      "1   DB      203   25393  0.799433\n",
      "2  NAS      541   12977  4.168914\n",
      "3   RM     3016   82952  3.635838\n",
      "4   SS      184   15642  1.176320\n",
      "5  WPS      529   34781  1.520945\n",
      "6   WS      232    8964  2.588130\n",
      "7  WSM     8916  329355  2.707109\n"
     ]
    }
   ],
   "source": [
    "print(res)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "59d26eff",
   "metadata": {},
   "outputs": [],
   "source": [
    "relative = res_df.merge(res[['app', 'RFR']], how='left', on=['app'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "74906ce6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   app       mean       std       n      conf       RFR\n",
      "0  DAE  58.363853  0.214614    3712  0.690415  9.111378\n",
      "1   DB  40.871582  0.266851   21367  0.357810  0.799433\n",
      "2  NAS  64.447986  0.089612    1783  0.415955  4.168914\n",
      "3   RM  63.851844  0.272396   52312  0.233430  3.635838\n",
      "4   SS  42.995601  0.263398   12477  0.462182  1.176320\n",
      "5  WPS  28.246709  0.095436   11993  0.170807  1.520945\n",
      "6   WS  71.073615  0.241670    7260  0.555918  2.588130\n",
      "7  WSM  63.000880  0.173798  169258  0.082799  2.707109\n"
     ]
    }
   ],
   "source": [
    "print(relative)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "c9aa4a6e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.5476190476190477"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "relative['RFR'].corr(relative['mean'],method='spearman')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "e47a6a31",
   "metadata": {},
   "outputs": [],
   "source": [
    "# DAE的RFR特别高，针对这一情况进一步分析\n",
    "df_all = pd.read_csv(\"data/20191231.csv\")\n",
    "df_all = df_all.merge(df_topo[['model', 'disk_id', 'app']], how='left', on=['model', 'disk_id'])\n",
    "df_all = df_all[df_all['app'] == 'DAE']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "d3dbd04c",
   "metadata": {},
   "outputs": [],
   "source": [
    "DAE_model = df_all[['app', 'model']] \n",
    "DAE_model = DAE_model.groupby(['model']).count().reset_index().rename(columns={'app':'cnt'})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "928d00d2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   model   cnt\n",
      "0     A1  1113\n",
      "1     A2   192\n",
      "2     A3    12\n",
      "3     A4    12\n",
      "4     A5    11\n",
      "5     A6    48\n",
      "6     B1     3\n",
      "7     B2   235\n",
      "8     B3  2149\n",
      "9     C1  8228\n",
      "10    C2  1321\n"
     ]
    }
   ],
   "source": [
    "print(DAE_model)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "4ef3b5d0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "13324\n"
     ]
    }
   ],
   "source": [
    "print(df_all.shape[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "bfbef09b",
   "metadata": {},
   "outputs": [],
   "source": [
    "DAE_model['proportion'] = DAE_model['cnt'] * 100 / df_all.shape[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "c29fa605",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   model   cnt  proportion\n",
      "0     A1  1113    8.353347\n",
      "1     A2   192    1.441009\n",
      "2     A3    12    0.090063\n",
      "3     A4    12    0.090063\n",
      "4     A5    11    0.082558\n",
      "5     A6    48    0.360252\n",
      "6     B1     3    0.022516\n",
      "7     B2   235    1.763735\n",
      "8     B3  2149   16.128790\n",
      "9     C1  8228   61.753227\n",
      "10    C2  1321    9.914440\n"
     ]
    }
   ],
   "source": [
    "print(DAE_model)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "4b2eb6d5",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 分析WPS\n",
    "df_all = pd.read_csv(\"data/20191231.csv\")\n",
    "df_all = df_all.merge(df_topo[['model', 'disk_id', 'app']], how='left', on=['model', 'disk_id'])\n",
    "df_all = df_all[df_all['app'] == 'WPS']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "0f200963",
   "metadata": {},
   "outputs": [],
   "source": [
    "WPS_model = df_all[['app', 'model']] \n",
    "WPS_model = WPS_model.groupby(['model']).count().reset_index().rename(columns={'app':'cnt'})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "e7280d9b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   model    cnt\n",
      "0     A1   7489\n",
      "1     A2     24\n",
      "2     A3      6\n",
      "3     A4     27\n",
      "4     A5     61\n",
      "5     A6     12\n",
      "6     B1   1002\n",
      "7     B2   1653\n",
      "8     B3   2739\n",
      "9     C1  21261\n",
      "10    C2    507\n"
     ]
    }
   ],
   "source": [
    "print(WPS_model)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "ebb2e340",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "34781\n"
     ]
    }
   ],
   "source": [
    "print(df_all.shape[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "34e13d00",
   "metadata": {},
   "outputs": [],
   "source": [
    "WPS_model['proportion'] = WPS_model['cnt'] * 100 / df_all.shape[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "42c95428",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   model    cnt  proportion\n",
      "0     A1   7489   21.531871\n",
      "1     A2     24    0.069003\n",
      "2     A3      6    0.017251\n",
      "3     A4     27    0.077629\n",
      "4     A5     61    0.175383\n",
      "5     A6     12    0.034502\n",
      "6     B1   1002    2.880883\n",
      "7     B2   1653    4.752595\n",
      "8     B3   2739    7.874989\n",
      "9     C1  21261   61.128202\n",
      "10    C2    507    1.457692\n"
     ]
    }
   ],
   "source": [
    "print(WPS_model)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "c37e7f9d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  model    cnt  proportion\n",
      "0    A1  15409   60.682078\n",
      "1    A2   3487   13.732131\n",
      "2    A3   1461    5.753554\n",
      "3    A4     72    0.283543\n",
      "4    A5     22    0.086638\n",
      "5    A6   1548    6.096168\n",
      "6    B1    217    0.854566\n",
      "7    B2   1558    6.135549\n",
      "8    B3    820    3.229236\n",
      "9    C1    799    3.146536\n"
     ]
    }
   ],
   "source": [
    "# 分析DB\n",
    "df_all = pd.read_csv(\"data/20191231.csv\")\n",
    "df_all = df_all.merge(df_topo[['model', 'disk_id', 'app']], how='left', on=['model', 'disk_id'])\n",
    "df_all = df_all[df_all['app'] == 'DB']\n",
    "DB_model = df_all[['app', 'model']] \n",
    "DB_model = DB_model.groupby(['model']).count().reset_index().rename(columns={'app':'cnt'})\n",
    "DB_model['proportion'] = DB_model['cnt'] * 100 / df_all.shape[0]\n",
    "print(DB_model)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "03bf10cd",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_topo = pd.read_csv(\"data/location_info_of_ssd.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "d4c86513",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_mean = pd.DataFrame()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "848aa49f",
   "metadata": {},
   "outputs": [],
   "source": [
    "apps = ['WSM', 'RM', 'DAE', 'NAS', 'WS']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "9511cf28",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = df_topo[df_topo['app'].isin(apps)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "9f6ce235",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_mean = df.groupby(['app', 'node_id'])['disk_id'].count().reset_index().groupby(['app'])['disk_id'].mean().reset_index().rename(columns={'disk_id':'mean'})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "91de694a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:xlabel='Applications', ylabel='Average number of SSDs per node'>"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEGCAYAAABiq/5QAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAY6UlEQVR4nO3daZglZZmn8fsPaLPIZlPYCEqhw+Au2DWoKMrSuLEpolCCo2CDH1zQVht0BBxtW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29g+yUsGlvdJctRkY5Kmk4lfa5r5wA+Zpqurq+rvJ1lwbnvg/sRfVWdU1XHTEZM0VSZ+rTGSPAJ4Ls3Vxge2bbskuTDJt5Nck+RT7VWVJPmvts76lUnOa6/aHr/N749V3kzyoiSXpblnw3lt245JfpTk8iQXJdkuycOB9wIHtBf1HZDktWlr9Kep4/+9JD9r+31s2/75NPXcL0py3cC3ji3a9zB2T4Cde9+ZWqOZ+LUm2Rc4qy2m9/skf9u27wi8CXgS8HiWV0jcAFjY3ofhAgbuwTBe+6HwGeDlVfV0mrr7AFcDO1fVDsAxwD+3V2UeA3ylLd43vnDbvwEnVdXTgC8BHxtYtwXNh9dewNg3hFcBZ7f1gp4OLOq2O6QVM/FrTTKfpkQy7e+x4Z6fVNV1bQmJk2kSKzQVFMeS8hcH2lfkWcCFbcmOsVpGABsDX20v0/8wD7w5x8o8m6aELzTlLQb7Pb2q7muHlx7Vtl0CHJLmrmZPraqlHfqQVsrErzVCWx56N+CzbfXQd9AUlQswvi7JyuqUTKZ+yfuA89u7c+0NTPU+BHcPPA5AVV0IPA+4Efh8kv85xT404kz8WlPsD3yhqrZuq4c+hua2iDsDOybZph3bP4Dm5C80f//7t49fNdC+Ij8Gnpfl91B9ZNu+MU1CBnjtwPOXAhuuZFsXsbzC60HAD1byPNq+tgZuqarPAJ8FnjHR86VVMfFrTTGfpuTtoK+17ZfQVEm8iubDYOx5d9B8KFxB823hvSvbeFUtprkl59eT/JTlQ0QfBD6Q5HJgsFTz+TSVSxclOeCBW+NNNEM3P6OpanrEKt7bLsBP2z4OAD66iudLE7I6p9ZoSXYB3l5Ve61g3X9V1SOGHpQ0wzzil6QR4xG/JI0Yj/glacSY+CVpxJj4JWnEmPglacSY+CVpxPx/+l06ilAapmAAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "df_mean.plot(x = 'app', y = 'mean', kind='bar', rot = 0, xlabel = 'Applications', ylabel = 'Average number of SSDs per node', legend = None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "1a6d8847",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>app</th>\n",
       "      <th>failure</th>\n",
       "      <th>all</th>\n",
       "      <th>RFR</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>DAE</td>\n",
       "      <td>1214</td>\n",
       "      <td>13324</td>\n",
       "      <td>9.111378</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>DB</td>\n",
       "      <td>203</td>\n",
       "      <td>25393</td>\n",
       "      <td>0.799433</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>NAS</td>\n",
       "      <td>541</td>\n",
       "      <td>12977</td>\n",
       "      <td>4.168914</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>RM</td>\n",
       "      <td>3016</td>\n",
       "      <td>82952</td>\n",
       "      <td>3.635838</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>SS</td>\n",
       "      <td>184</td>\n",
       "      <td>15642</td>\n",
       "      <td>1.176320</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>WPS</td>\n",
       "      <td>529</td>\n",
       "      <td>34781</td>\n",
       "      <td>1.520945</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>WS</td>\n",
       "      <td>232</td>\n",
       "      <td>8964</td>\n",
       "      <td>2.588130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>WSM</td>\n",
       "      <td>8916</td>\n",
       "      <td>329355</td>\n",
       "      <td>2.707109</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   app  failure     all       RFR\n",
       "0  DAE     1214   13324  9.111378\n",
       "1   DB      203   25393  0.799433\n",
       "2  NAS      541   12977  4.168914\n",
       "3   RM     3016   82952  3.635838\n",
       "4   SS      184   15642  1.176320\n",
       "5  WPS      529   34781  1.520945\n",
       "6   WS      232    8964  2.588130\n",
       "7  WSM     8916  329355  2.707109"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "2da1b5bd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>app</th>\n",
       "      <th>mean</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>DAE</td>\n",
       "      <td>4.421111</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>NAS</td>\n",
       "      <td>10.746468</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>RM</td>\n",
       "      <td>3.306394</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>WS</td>\n",
       "      <td>2.698509</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>WSM</td>\n",
       "      <td>4.556153</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   app       mean\n",
       "0  DAE   4.421111\n",
       "1  NAS  10.746468\n",
       "2   RM   3.306394\n",
       "3   WS   2.698509\n",
       "4  WSM   4.556153"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_mean"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "062f3b91",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>app</th>\n",
       "      <th>mean</th>\n",
       "      <th>std</th>\n",
       "      <th>n</th>\n",
       "      <th>conf</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>DAE</td>\n",
       "      <td>58.363853</td>\n",
       "      <td>0.214614</td>\n",
       "      <td>3712</td>\n",
       "      <td>0.690415</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>DB</td>\n",
       "      <td>40.871582</td>\n",
       "      <td>0.266851</td>\n",
       "      <td>21367</td>\n",
       "      <td>0.357810</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>NAS</td>\n",
       "      <td>64.447986</td>\n",
       "      <td>0.089612</td>\n",
       "      <td>1783</td>\n",
       "      <td>0.415955</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>RM</td>\n",
       "      <td>63.851844</td>\n",
       "      <td>0.272396</td>\n",
       "      <td>52312</td>\n",
       "      <td>0.233430</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>SS</td>\n",
       "      <td>42.995601</td>\n",
       "      <td>0.263398</td>\n",
       "      <td>12477</td>\n",
       "      <td>0.462182</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>WPS</td>\n",
       "      <td>28.246709</td>\n",
       "      <td>0.095436</td>\n",
       "      <td>11993</td>\n",
       "      <td>0.170807</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>WS</td>\n",
       "      <td>71.073615</td>\n",
       "      <td>0.241670</td>\n",
       "      <td>7260</td>\n",
       "      <td>0.555918</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>WSM</td>\n",
       "      <td>63.000880</td>\n",
       "      <td>0.173798</td>\n",
       "      <td>169258</td>\n",
       "      <td>0.082799</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   app       mean       std       n      conf\n",
       "0  DAE  58.363853  0.214614    3712  0.690415\n",
       "1   DB  40.871582  0.266851   21367  0.357810\n",
       "2  NAS  64.447986  0.089612    1783  0.415955\n",
       "3   RM  63.851844  0.272396   52312  0.233430\n",
       "4   SS  42.995601  0.263398   12477  0.462182\n",
       "5  WPS  28.246709  0.095436   11993  0.170807\n",
       "6   WS  71.073615  0.241670    7260  0.555918\n",
       "7  WSM  63.000880  0.173798  169258  0.082799"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "9b9ccffa",
   "metadata": {},
   "outputs": [],
   "source": [
    "test =  df_mean.merge(res[['app', 'RFR']], how = 'left', on = ['app'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "35bc0db1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.49999999999999994"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test['RFR'].corr(test['mean'], method = 'spearman')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "933348d6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>app</th>\n",
       "      <th>mean</th>\n",
       "      <th>RFR</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>DAE</td>\n",
       "      <td>4.421111</td>\n",
       "      <td>9.111378</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>NAS</td>\n",
       "      <td>10.746468</td>\n",
       "      <td>4.168914</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>RM</td>\n",
       "      <td>3.306394</td>\n",
       "      <td>3.635838</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>WS</td>\n",
       "      <td>2.698509</td>\n",
       "      <td>2.588130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>WSM</td>\n",
       "      <td>4.556153</td>\n",
       "      <td>2.707109</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   app       mean       RFR\n",
       "0  DAE   4.421111  9.111378\n",
       "1  NAS  10.746468  4.168914\n",
       "2   RM   3.306394  3.635838\n",
       "3   WS   2.698509  2.588130\n",
       "4  WSM   4.556153  2.707109"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "03b5f5cc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "app\n",
       "DAE     16000\n",
       "NAS     14454\n",
       "RM     183981\n",
       "WS      17740\n",
       "WSM    380170\n",
       "Name: disk_id, dtype: int64"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby(['app', 'node_id'])['disk_id'].count().reset_index().groupby(['app'])['disk_id'].sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "04abda21",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "app\n",
       "DAE     3619\n",
       "NAS     1345\n",
       "RM     55644\n",
       "WS      6574\n",
       "WSM    83441\n",
       "Name: disk_id, dtype: int64"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby(['app', 'node_id'])['disk_id'].count().reset_index().groupby(['app'])['disk_id'].count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "7631b61f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4.065414976464417"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 写主要应用程序每个节点的平均SSD数\n",
    "(16000 + 14454 + 183981 + 17740 + 380170) / (3619 + 1345 + 55644 + 6574 + 83441)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "1d826636",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_topo = pd.read_csv(\"data/location_info_of_ssd.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "d4184797",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_mean = pd.DataFrame()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "3305224b",
   "metadata": {},
   "outputs": [],
   "source": [
    "apps = ['DB', 'SS', 'WPS']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "93057685",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = df_topo[df_topo['app'].isin(apps)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "61b4abc5",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_mean = df.groupby(['app', 'node_id'])['disk_id'].count().reset_index().groupby(['app'])['disk_id'].mean().reset_index().rename(columns={'disk_id':'mean'})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "988c3d12",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:xlabel='Applications', ylabel='Average number of SSDs per node'>"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEICAYAAABYoZ8gAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAYOElEQVR4nO3de5QlZX3u8e8DaOQqeBgMijAj4WDQKJgJ8YKK4i0ygOGgiOARUHCtgwZNPIIXJCvGiB4xajgKw0U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+ZmtMMfs0lewFfrap/A36R5M/b9p2BNwA7ANsCe7ftGwJLq+qJwBIG3P+gfVM4EfgfVfUU4GXtru8Dz6qqnYB3Av9UVfe2259pF977zEqH+xfg1Kp6MvBJ4MOT9m1J8+a1CJj4DeGVwHnt/RyeAlzT7a9DWjWDX3PJfsCn2+1P8/vhnm9X1c1VdT9wOk2wQrP64kQof2JS+6o8Dbi4qn4E0K79Au3iX0muBf6ZZv33NXk6v19K4LSV+j2rqh5oh5ce3bZdARyU5O+BP6uqFR36kFbL4NeckORRwPOAk5LcAvxvmrswBVh5XZLVrVMylfVL3gVc1K7yuAfwiCkcY7J7Jm0HoKouBp4N/BT4eJL/Oc0+NOYMfs0V+wCnVdU2VTW/va/Bj4BnATsnWdCO7e9L8+EvNP/+92m3XzmpfVX+FXj2xP1X2zcaaM74f9puHzjp+Sto7qS2KpfSfgYB7A9cMugPlmQb4PaqOhE4CXjqoOdLa2Lwa67Yj+bet5N9rm2/gmaFxRto3gwmnncXzZvCtTS/LfzD6g5eVctobsDy+STf4fdDRO8D3pPkah682u1FwA4TH+6udLg30AzdfBd4Fc0Kn4PsCnyn7WNf4ENreL40kKtzak5r18r/3U1uVtr3oJvjSOPCM35JGjOe8UvSmPGMX5LGjMEvSWPG4JekMWPwS9KYMfglacwY/JI0Zv4/4GWfhbUprSgAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "df_mean.plot(x = 'app', y = 'mean', kind='bar', rot = 0, xlabel = 'Applications', ylabel = 'Average number of SSDs per node', legend = None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "90507b25",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "app\n",
       "DB     26781\n",
       "SS     32936\n",
       "WPS    44676\n",
       "Name: disk_id, dtype: int64"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby(['app', 'node_id'])['disk_id'].count().reset_index().groupby(['app'])['disk_id'].sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "aceb5caa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "app\n",
       "DB     2319\n",
       "SS     4593\n",
       "WPS    9003\n",
       "Name: disk_id, dtype: int64"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby(['app', 'node_id'])['disk_id'].count().reset_index().groupby(['app'])['disk_id'].count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "5c7b193f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6.172667295004713"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 读主要应用程序每个节点的平均SSD数\n",
    "(26781 + 26781 + 44676) / (2319 + 4593 + 9003)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "dbb2ae17",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>app</th>\n",
       "      <th>failure</th>\n",
       "      <th>all</th>\n",
       "      <th>RFR</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>DAE</td>\n",
       "      <td>1214</td>\n",
       "      <td>13324</td>\n",
       "      <td>9.111378</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>DB</td>\n",
       "      <td>203</td>\n",
       "      <td>25393</td>\n",
       "      <td>0.799433</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>NAS</td>\n",
       "      <td>541</td>\n",
       "      <td>12977</td>\n",
       "      <td>4.168914</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>RM</td>\n",
       "      <td>3016</td>\n",
       "      <td>82952</td>\n",
       "      <td>3.635838</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>SS</td>\n",
       "      <td>184</td>\n",
       "      <td>15642</td>\n",
       "      <td>1.176320</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>WPS</td>\n",
       "      <td>529</td>\n",
       "      <td>34781</td>\n",
       "      <td>1.520945</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>WS</td>\n",
       "      <td>232</td>\n",
       "      <td>8964</td>\n",
       "      <td>2.588130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>WSM</td>\n",
       "      <td>8916</td>\n",
       "      <td>329355</td>\n",
       "      <td>2.707109</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   app  failure     all       RFR\n",
       "0  DAE     1214   13324  9.111378\n",
       "1   DB      203   25393  0.799433\n",
       "2  NAS      541   12977  4.168914\n",
       "3   RM     3016   82952  3.635838\n",
       "4   SS      184   15642  1.176320\n",
       "5  WPS      529   34781  1.520945\n",
       "6   WS      232    8964  2.588130\n",
       "7  WSM     8916  329355  2.707109"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "fe6a1f76",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.109890699150081"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 写主要应用程序的RFR\n",
    "(1214 + 541 + 3016 + 232 + 8916) * 100 / (13324 + 12977 + 82952 + 8964 + 329355)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "a27df9b6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.2081882452252823"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 读主要应用程序的RFR\n",
    "(203 + 184 + 529) * 100 / (25393 + 15642 + 34781)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8d500351",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
